diff -urpN fckeditor_old/fckeditor.admin.inc fckeditor/fckeditor.admin.inc
--- fckeditor_old/fckeditor.admin.inc	2009-03-24 17:11:30.000000000 +0100
+++ fckeditor/fckeditor.admin.inc	2009-05-15 10:07:00.966200000 +0200
@@ -591,7 +591,9 @@ function fckeditor_admin_profile_form($f
     '#options' => array(
       'theme' => t('Use theme fckstyles.xml'),
       'self' => t('Define path to fckstyles.xml'),
-      'default' => t('FCKeditor default')
+      'default' => t('FCKeditor default'),
+      'module' => t('Use fckstyles generated based on the stylesheets of your theme. Will create a file if it doesn\'t exist yet.'),
+      'module_regenerate' => t('Use fckstyles generated based on the stylesheets of your theme. Will regenerate the fckstyles file.')
     ),
     '#description' => t('Define the location of "fckstyles.xml" file. It is used by the "Style" dropdown list available in the default toolbar. Copy "!fckstyles.xml" inside your theme directory ("!theme") and adjust it to your needs.', array('!fckstyles.xml' => fckeditor_path(TRUE) .'/fckstyles.xml', '!theme' => path_to_theme() .'/fckstyles.xml'))
   );
@@ -798,6 +800,19 @@ function fckeditor_admin_profile_form_va
 }
 
 function fckeditor_admin_profile_form_submit($form, &$form_state) {
+  if ($form_state['values']['css_style'] == 'module_regenerate' || $form_state['values']['css_style'] == 'module') {
+    $styles_xml_path = file_create_path('fckeditor');
+    
+    if (!file_exists($styles_xml_path .'/fckeditor.styles.xml') || $form_state['values']['css_style'] == 'module_regenerate') {
+      include_once(drupal_get_path('module', 'fckeditor') .'/fckeditor.styles.inc');
+      $styles_xml = fckeditor_xml_styles($form_state['values']);
+      file_check_directory($styles_xml_path, FILE_CREATE_DIRECTORY);
+      file_save_data($styles_xml, $styles_xml_path .'/fckeditor.styles.xml', FILE_EXISTS_REPLACE);
+      drupal_set_message(t('XML Styles file saved in: @styles', array('@styles' => $styles_xml_path .'/fckeditor.styles.xml')));
+      $form_state['values']['css_style'] = 'module';
+    }
+  }
+  
   $edit =& $form_state['values'];
 
   if (isset($edit['_profile'])) {
diff -urpN fckeditor_old/fckeditor.module fckeditor/fckeditor.module
--- fckeditor_old/fckeditor.module	2009-05-14 12:48:22.000000000 +0200
+++ fckeditor/fckeditor.module	2009-05-15 10:06:57.378200000 +0200
@@ -774,6 +774,10 @@ function fckeditor_process_textarea($ele
       $conf['styles_path'] = str_replace("%h%t", "%t", $conf['styles_path']);
       $js .=  $js_id .".Config['StylesXmlPath'] = \"". str_replace(array('%h', '%t', '%m'), array($host, $host . $themepath, $module_drupal_path), $conf['styles_path']) ."\";\n";
     }
+    else if ($conf['css_style'] == 'module') {
+      $styles_xml_path = file_create_path('fckeditor');
+      $js .=  $js_id .".Config['StylesXmlPath'] = \"". url($styles_xml_path .'/fckeditor.styles.xml') ."\";\n";
+    }
     // add custom stylesheet if configured
     // lets hope it exists but we'll leave that to the site admin
     $cssfiles = array($module_full_path .'/fckeditor.css');
diff -urpN fckeditor_old/fckeditor.styles.inc fckeditor/fckeditor.styles.inc
--- fckeditor_old/fckeditor.styles.inc	1970-01-01 01:00:00.000000000 +0100
+++ fckeditor/fckeditor.styles.inc	2009-05-15 10:07:03.758600000 +0200
@@ -0,0 +1,173 @@
+<?php
+// $Id$
+/**
+ * FCKeditor - The text editor for Internet - http://www.fckeditor.net
+ * Copyright (C) 2003-2008 Frederico Caldeira Knabben
+ *
+ * == BEGIN LICENSE ==
+ *
+ * Licensed under the terms of any of the following licenses at your
+ * choice:
+ *
+ *  - GNU General Public License Version 2 or later (the "GPL")
+ *    http://www.gnu.org/licenses/gpl.html
+ *
+ *  - GNU Lesser General Public License Version 2.1 or later (the "LGPL")
+ *    http://www.gnu.org/licenses/lgpl.html
+ *
+ *  - Mozilla Public License Version 1.1 or later (the "MPL")
+ *    http://www.mozilla.org/MPL/MPL-1.1.html
+ *
+ * == END LICENSE ==
+ *
+ * @file
+ * FCKeditor Module for Drupal 6.x
+ *
+ * This module allows Drupal to replace textarea fields with FCKeditor.
+ *
+ * This HTML text editor brings to the web many of the powerful functionalities
+ * of known desktop editors like Word. It's really  lightweight and doesn't
+ * require any kind of installation on the client computer.
+ */
+
+function fckeditor_xml_styles($css_profile) {
+  global $theme_info, $base_theme_info;
+  $css_file = '';
+  
+  if (!empty($base_theme_info->stylesheets)) {
+    foreach ($base_theme_info as $base) {
+      foreach ($base->stylesheets as $type => $stylesheets) {
+        if ($type != "print") {
+          foreach ($stylesheets as $name => $path) {
+            if (file_exists($path)) {
+              $css_file .= file_get_contents($path);
+            }
+          }
+        }
+      }
+    }
+  }
+  if (!empty($theme_info->stylesheets)) {
+    foreach ($theme_info->stylesheets as $type => $stylesheets) {
+      if ($type != "print") {
+        foreach ($stylesheets as $name => $path) {
+          if (file_exists($path)) {
+            $css_file .= file_get_contents($path);
+          }
+        }
+      }
+    }
+  }
+
+  //remove comments
+  $css_file = preg_replace('|/\*.*?\*/|ms', '', $css_file);
+
+  //break up css statements
+  preg_match_all('/[^{]+{([^}]*)}/ms', $css_file, $css_statements, PREG_SET_ORDER);
+  /*
+    Array
+    (
+      [0] => Array
+        (
+          [0] => * { font-size: 100.01%; }
+          [1] => font-size: 100.01%; 
+        )
+    )
+  */
+  
+  $styles = array();
+  
+  //loop through the css statements
+  foreach ($css_statements as $css_statement) {
+    preg_match_all('/([^{]+){([^}]*)}/ms', $css_statement[0], $css_parts);
+    /*
+      Array
+      (
+        [0] => * { font-size: 100.01%; }
+        [1] => * 
+        [2] => font-size: 100.01%; 
+      )
+    */
+
+    //loop through the selectors
+    $selectors = explode(',', $css_parts[1][0]);
+    foreach ($selectors as $selector) {    
+      //only works on css selectors consisting of a single class or a single html tag
+      if (preg_match('/^([\s])*([a-zA-Z0-9\-]*[\.#]{1}[a-zA-Z0-9\-]+)([\s])*$/', $selector) > 0) {
+        //remove white space from selector
+        $selector = preg_replace('/\s/', '', $selector);
+        
+        //remove new lines and extra whitespaces from the css
+        $css_parts[2] = trim(preg_replace('/([\s])+/', ' ', $css_parts[2]));
+
+        //contains a class
+        if (strstr($selector, ".") !== FALSE) {
+          $styles[$selector] = CSS_CLASS;//(isset($classes[$selector]) ? $classes[$selector] : '') .$cssParts[2];
+        }
+        //contains an id
+        else {
+          $styles[$selector] = CSS_ID;//(isset($ids[$selector]) ? $ids[$selector] : '').$cssParts[2];
+        }
+      }
+    }
+  }
+  
+  //create xml
+  /*
+    <?xml version="1.0" encoding="utf-8" ?>
+    <Styles>
+      <Style name="Image on Left" element="img">
+        <Attribute name="style" value="padding: 5px; margin-right: 5px" />
+        <Attribute name="border" value="2" />
+        <Attribute name="align" value="left" />
+      </Style>
+    </Styles>
+  */
+  
+  //header('Content-Type: text/xml');
+  $xml  = '<?xml version="1.0" encoding="utf-8" ?>';
+  $xml .= '<Styles>';
+    $styles_parsed = array();
+    foreach ($styles as $selector => $type) {
+      if($type == ID) {
+        $selector_parts = explode("#", $selector);
+        if (in_array($selector_parts[0], array('body'))) continue;
+        if (!empty($selector_parts[0])) {
+          $styles_parsed[$selector_parts[1]] = '
+            <Style name="'.$selector_parts[1].'" element="'.$selector_parts[0].'">
+              <Attribute name="id" value="'.$selector_parts[1].'" />
+            </Style>
+          ';
+        }
+        else {
+          $styles_parsed[$selector_parts[1]] = '
+            <Style name="'.$selector_parts[1].'" element="span">
+              <Attribute name="id" value="'.$selector_parts[1].'" />
+            </Style>
+          ';
+        }
+      }
+      elseif ($type == CSS_CLASS) {
+        $selector_parts = explode(".", $selector);
+        if (in_array($selector_parts[0], array('body'))) continue;
+        if (!empty($selector_parts[0])) {
+          $styles_parsed[$selector_parts[1]] = '
+            <Style name="'.$selector_parts[1].'" element="'.$selector_parts[0].'">
+              <Attribute name="class" value="'.$selector_parts[1].'" />
+            </Style>
+          ';
+        }
+        else {
+          $styles_parsed[$selector_parts[1]] = '
+            <Style name="'.$selector_parts[1].'" element="span">
+              <Attribute name="class" value="'.$selector_parts[1].'" />
+            </Style>
+          ';
+        }
+      }
+    }
+    ksort($styles_parsed);
+    $xml .= implode('', $styles_parsed);
+  $xml .= '</Styles>';
+  return $xml;
+}
\ No newline at end of file
