El 10.04.2017 a las 11:05, Jean-Marc Lasgouttes escribió:

These environment always put the result its own page for technical reasons. All the original reporter said is "I think the 'Here if possible' and 'Here definitely' GUI options should still remain available".

I think we have here the same case as with \baselineskip. LaTeX allows all placement options. They might not be sensible but if the user wants to use them we should not forbid them like we do not forbid \baselineskip as horizontal length.

I rethought the patch and think a fileformat is necessary. Attached is an updated patch where I for now disabled the top and bottom placement ans you proposed.

thanks and regards
Uwe
 development/FORMAT                   |  4 +++
 lib/lyx2lyx/lyx_2_3.py               | 49 +++++++++++++++++++++++++++++++++++-
 src/frontends/qt4/FloatPlacement.cpp |  9 ++++---
 src/insets/InsetFloat.cpp            |  2 +-
 src/tex2lyx/text.cpp                 |  5 ++++
 src/version.h                        |  4 +--
 6 files changed, 65 insertions(+), 8 deletions(-)

diff --git a/development/FORMAT b/development/FORMAT
index 13dad66442..0a2de0370d 100644
--- a/development/FORMAT
+++ b/development/FORMAT
@@ -7,6 +7,10 @@ changes happened in particular if possible. A good example 
would be
 
 -----------------------
 
+2017-04-11 Uwe Stöhr <uwesto...@web.de>
+       * Format incremented to 540: support for rotated float placements
+         - no new LFUN or buffer parameters
+
 2017-04-08 Uwe Stöhr <uwesto...@web.de>
        * Format incremented to 539: support for \baselineskip.
          - new length unit BLS
diff --git a/lib/lyx2lyx/lyx_2_3.py b/lib/lyx2lyx/lyx_2_3.py
index 392f5e5dbc..23eee11d11 100644
--- a/lib/lyx2lyx/lyx_2_3.py
+++ b/lib/lyx2lyx/lyx_2_3.py
@@ -2063,6 +2063,51 @@ def revert_baselineskip(document):
     i = i + 1
 
 
+def revert_rotfloat(document):
+  " Revert placement options for rotated floats "
+  i = 0
+  j = 0
+  k = 0
+  while True:
+    i = find_token(document.body, "sideways true", i)
+    if i != -1:
+      regexp = re.compile(r'^.*placement.*$')
+      j = find_re(document.body, regexp, i-2)
+      if j == -1:
+          return
+      if j != i-2:
+          i = i + 1
+          continue
+    else:
+      return
+    # we found a sideways float with placement options
+    # at first store the placement
+    beg = document.body[i-2].rfind(" ");
+    placement = document.body[i-2][beg+1:]
+    # check if the option'H' is used
+    if placement.find("H") != -1:
+      add_to_preamble(document, ["\\usepackage{float}"])  
+    # now check if it is a starred type
+    if document.body[i-1].find("wide true") != -1:
+      star = '*'
+    else:
+      star = ''
+    # store the float type
+    beg = document.body[i-3].rfind(" ");
+    fType = document.body[i-3][beg+1:]
+    # now output TeX code
+    endInset = find_end_of_inset(document.body, i-3)
+    if endInset == -1:
+      document.warning("Malformed LyX document: Missing '\\end_inset' of Float 
inset.")
+      return
+    else:
+      document.body[endInset-2: endInset+1] = put_cmd_in_ert("\\end{sideways" 
+ fType + star + '}')
+      document.body[i-3: i+2] = put_cmd_in_ert("\\begin{sideways" + fType + 
star + "}[" + placement + ']')
+      add_to_preamble(document, ["\\usepackage{rotfloat}"])  
+    
+    i = i + 1
+
+
 ##
 # Conversion hub
 #
@@ -2099,10 +2144,12 @@ convert = [
            [536, []],
            [537, []],
            [538, [convert_mathindent]],
-           [539, []]
+           [539, []],
+           [540, []]
           ]
 
 revert =  [
+           [539, [revert_rotfloat]],
            [538, [revert_baselineskip]],
            [537, [revert_mathindent]],
            [536, [revert_xout]],
diff --git a/src/frontends/qt4/FloatPlacement.cpp 
b/src/frontends/qt4/FloatPlacement.cpp
index b446c7c057..d0c7a58bcf 100644
--- a/src/frontends/qt4/FloatPlacement.cpp
+++ b/src/frontends/qt4/FloatPlacement.cpp
@@ -244,18 +244,19 @@ void FloatPlacement::checkAllowed() const
        if (spanCB->isVisible()) {
                bool const span = spanCB->isChecked();
                bool const sideways = sidewaysCB->isChecked();
-               defaultsCB->setEnabled(!sideways);
                topCB->setEnabled(!sideways && !defaults && !heredefinitely
                                  && contains(allowed_placement_, 't'));
                bottomCB->setEnabled(!sideways && !defaults && !span && 
!heredefinitely
                                     && contains(allowed_placement_, 'b'));
                pageCB->setEnabled(!sideways && !defaults && !heredefinitely
                                   && contains(allowed_placement_, 'p'));
-               herepossiblyCB->setEnabled(!sideways && !defaults && !span && 
!heredefinitely
+               if (!pageCB->isChecked())
+                       pageCB->setChecked(sideways && 
contains(allowed_placement_, 'p'));
+               herepossiblyCB->setEnabled(!defaults && !span && !heredefinitely
                                           && contains(allowed_placement_, 
'h'));
-               heredefinitelyCB->setEnabled(!sideways && !defaults && !span
+               heredefinitelyCB->setEnabled(!defaults && !span
                                             && contains(allowed_placement_, 
'H'));
-               ignoreCB->setEnabled(!sideways && !defaults && ignore && 
!heredefinitely
+               ignoreCB->setEnabled(!defaults && ignore && !heredefinitely
                                     && contains(allowed_placement_, '!'));
                spanCB->setEnabled(allows_wide_ && (!sideways || 
standardfloat_));
                sidewaysCB->setEnabled(allows_sideways_);
diff --git a/src/insets/InsetFloat.cpp b/src/insets/InsetFloat.cpp
index 7a95178227..c3feb0e5ba 100644
--- a/src/insets/InsetFloat.cpp
+++ b/src/insets/InsetFloat.cpp
@@ -390,7 +390,7 @@ void InsetFloat::latex(otexstream & os, OutputParams const 
& runparams_in) const
                os.texrow().start(runparams.lastid, runparams.lastpos);
        // We only output placement if different from the def_placement.
        // sidewaysfloats always use their own page
-       if (!placement.empty() && !params_.sideways)
+       if (!placement.empty())
                os << '[' << from_ascii(placement) << ']';
        os << '\n';
 
diff --git a/src/tex2lyx/text.cpp b/src/tex2lyx/text.cpp
index d28ed5a0cb..811883e9f1 100644
--- a/src/tex2lyx/text.cpp
+++ b/src/tex2lyx/text.cpp
@@ -1468,6 +1468,7 @@ void parse_environment(Parser & p, ostream & os, bool 
outer,
        else if (unstarred_name == "sidewaysfigure"
                || unstarred_name == "sidewaystable"
                || unstarred_name == "sidewaysalgorithm") {
+               string const opt = p.hasOpt() ? p.getArg('[', ']') : string();
                eat_whitespace(p, os, parent_context, false);
                parent_context.check_layout(os);
                if (unstarred_name == "sidewaysfigure")
@@ -1476,6 +1477,10 @@ void parse_environment(Parser & p, ostream & os, bool 
outer,
                        begin_inset(os, "Float table\n");
                else if (unstarred_name == "sidewaysalgorithm")
                        begin_inset(os, "Float algorithm\n");
+               if (!opt.empty())
+                       os << "placement " << opt << '\n';
+               if (contains(opt, "H"))
+                       preamble.registerAutomaticallyLoadedPackage("float");
                os << "wide " << convert<string>(is_starred)
                   << "\nsideways true"
                   << "\nstatus open\n\n";
diff --git a/src/version.h b/src/version.h
index f119480f53..ff15d4d973 100644
--- a/src/version.h
+++ b/src/version.h
@@ -32,8 +32,8 @@ extern char const * const lyx_version_info;
 
 // Do not remove the comment below, so we get merge conflict in
 // independent branches. Instead add your own.
-#define LYX_FORMAT_LYX 539 // uwestoehr: support for \baselineskip
-#define LYX_FORMAT_TEX2LYX 539
+#define LYX_FORMAT_LYX 540 // uwestoehr: enable placement for rotated floats
+#define LYX_FORMAT_TEX2LYX 540
 
 #if LYX_FORMAT_TEX2LYX != LYX_FORMAT_LYX
 #ifndef _MSC_VER

Reply via email to