[Libreoffice-commits] core.git: 6 commits - cui/source cui/uiconfig

Katarina Behrens Katarina.Behrens at cib.de
Tue Oct 25 09:27:31 UTC 2016


 cui/source/dialogs/screenshotannotationdlg.cxx |   81 +++++++++++++++++++++++--
 cui/uiconfig/ui/screenshotannotationdialog.ui  |   75 +++++++++++++----------
 2 files changed, 121 insertions(+), 35 deletions(-)

New commits:
commit fab262f115e5c0e6d43b65e376241152ddff82b3
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Mon Oct 24 21:58:38 2016 +0200

    screenshot annotation: More readable markup
    
    this should placate clang too
    
    Change-Id: Ida2cceebd5870b5896fb125e51e4cb67ad253d92

diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx
index 53a0cc9..cd0591d 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -54,38 +54,45 @@ namespace
 
     OUString lcl_AltDescr()
     {
-        OUString aRet = OUString("<alt xml-lang=en-US ") + OUString("id=") + lcl_genRandom("alt_id") + OUString(">") +
-                        OUString(" ") + //FIXME real dialog title or something
-                        OUString("</alt>");
-        return aRet;
+        OUString aTempl = OUString("<alt xml-lang=en-US id=%1>"
+                                   " " //FIXME real dialog title or something
+                                  "</alt>");
+        aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("alt_id") );
+
+        return aTempl;
     }
 
     OUString lcl_Image( const OUString& rScreenshotId )
     {
-        OUString aRet = OUString("<image id=") + lcl_genRandom( "img_id" ) +
-                        OUString(" src=media/screenshots/") + rScreenshotId + OUString(".png")
-                        + OUString(">") + //FIXME width + height
-                        lcl_AltDescr() +
-                        OUString("</image>");
-        return aRet;
+        OUString aTempl = OUString("<image id=%1 src=media/screenshots/%2.png>" //FIXME width + height
+                                    "%3"
+                                   "</image>");
+        aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("img_id") );
+        aTempl = aTempl.replaceFirst( "%2", rScreenshotId );
+        aTempl = aTempl.replaceFirst( "%3", lcl_AltDescr() );
+
+        return aTempl;
     }
 
     OUString lcl_ParagraphWithImage( const OUString& rScreenshotId )
     {
-        OUString aRet = OUString("<paragraph id=") + lcl_genRandom( "par_id" ) +
-                        OUString(" role=\"paragraph\" xml-lang=en-US>") +
-                        lcl_Image( rScreenshotId ) +
-                        OUString("</paragraph>");
-        return aRet;
+        OUString aTempl = OUString( "<paragraph id=%1 role=\"paragraph\" xml-lang=en-US>%2"
+                                    "</paragraph>"  SAL_NEWLINE_STRING );
+        aTempl = aTempl.replaceFirst( "%1", lcl_genRandom("par_id") );
+        aTempl = aTempl.replaceFirst( "%2", lcl_Image(rScreenshotId) );
+
+        return aTempl;
     }
 
     OUString lcl_Bookmark( const OUString& rWidgetId )
     {
-        OUString aRet = "<!-- Bookmark for widget " + rWidgetId + " -->"  + SAL_NEWLINE_STRING;
-        aRet += OUString("<bookmark xml-lang=en-US branch=hid/") + rWidgetId + OUString(" ") +
-                        lcl_genRandom( "bm_id" ) + OUString(" localize=false") +
-                        OUString("</bookmark>") + SAL_NEWLINE_STRING;
-        return aRet;
+        OUString aTempl = "<!-- Bookmark for widget %1 -->" SAL_NEWLINE_STRING
+                          "<bookmark xml-lang=en-US branch=hid/%2 %3 localize=false </bookmark>" SAL_NEWLINE_STRING;
+        aTempl = aTempl.replaceFirst( "%1", rWidgetId );
+        aTempl = aTempl.replaceFirst( "%2", rWidgetId );
+        aTempl = aTempl.replaceFirst( "%3", lcl_genRandom("bm_id") );
+
+        return aTempl;
     }
 }
 
commit ae3fb69ebca4e253959cdf9bf620296e7797a501
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Mon Oct 24 15:16:37 2016 +0200

    screenshot annotation: put back removed fields
    
    I hate you loplugin !!!
    
    Change-Id: I01067b04005a59b7ecb10a5a72ab6090b7f040a8

diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx
index ca56d1f..53a0cc9 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -92,8 +92,11 @@ namespace
 class ControlDataEntry
 {
 public:
-    ControlDataEntry(const basegfx::B2IRange& rB2IRange)
-        : maB2IRange(rB2IRange)
+    ControlDataEntry(
+        const vcl::Window& rControl,
+        const basegfx::B2IRange& rB2IRange)
+        : mrControl(rControl),
+        maB2IRange(rB2IRange)
     {
     }
 
@@ -105,6 +108,7 @@ public:
     const OString GetHelpId() const { return mrControl.GetHelpId(); }
 
 private:
+    const vcl::Window&  mrControl;
     basegfx::B2IRange   maB2IRange;
 };
 
@@ -251,7 +255,7 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl(
         OUString aHelpId = OStringToOUString( mrParentDialog.GetHelpId(), RTL_TEXTENCODING_UTF8 );
         maMainMarkupText = lcl_ParagraphWithImage( aHelpId);
         mpText->SetText( maMainMarkupText );
-        mpText->SetReadOnly(true);
+        mpText->SetReadOnly();
     }
 
     // set click handler for save button
@@ -275,7 +279,7 @@ void ScreenshotAnnotationDlg_Impl::CollectChildren(
 
         if (!aCurrentRange.isEmpty())
         {
-            rControlDataCollection.push_back(ControlDataEntry(aCurrentRange));
+            rControlDataCollection.push_back(ControlDataEntry(rCurrent, aCurrentRange));
         }
 
         for (sal_uInt16 a(0); a < rCurrent.GetChildCount(); a++)
commit dbecfbdde5956b49ac9b0a77c8310b34ff736791
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Mon Oct 24 10:47:10 2016 +0200

    screenshot annotation: Make this a default button
    
    Change-Id: I1a1db338696cf56062306a54a43c746a21a3431d

diff --git a/cui/uiconfig/ui/screenshotannotationdialog.ui b/cui/uiconfig/ui/screenshotannotationdialog.ui
index 71f0dff..76e368b 100644
--- a/cui/uiconfig/ui/screenshotannotationdialog.ui
+++ b/cui/uiconfig/ui/screenshotannotationdialog.ui
@@ -40,6 +40,8 @@
                 <property name="name">save</property>
                 <property name="visible">True</property>
                 <property name="can_focus">True</property>
+                <property name="can_default">True</property>
+                <property name="has_default">True</property>
                 <property name="receives_default">True</property>
               </object>
               <packing>
commit dcbfb99fc5755c63f6619c8668c28c314953da6e
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Oct 20 20:31:40 2016 +0200

    screenshot annotation: insert markup for annotated widgets
    
    Change-Id: I82b8c541239271e3acfa6d8ad45b752fa1554931

diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx
index 2f7c2d6..ca56d1f 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -78,6 +78,15 @@ namespace
                         OUString("</paragraph>");
         return aRet;
     }
+
+    OUString lcl_Bookmark( const OUString& rWidgetId )
+    {
+        OUString aRet = "<!-- Bookmark for widget " + rWidgetId + " -->"  + SAL_NEWLINE_STRING;
+        aRet += OUString("<bookmark xml-lang=en-US branch=hid/") + rWidgetId + OUString(" ") +
+                        lcl_genRandom( "bm_id" ) + OUString(" localize=false") +
+                        OUString("</bookmark>") + SAL_NEWLINE_STRING;
+        return aRet;
+    }
 }
 
 class ControlDataEntry
@@ -93,6 +102,8 @@ public:
         return maB2IRange;
     }
 
+    const OString GetHelpId() const { return mrControl.GetHelpId(); }
+
 private:
     basegfx::B2IRange   maB2IRange;
 };
@@ -156,6 +167,7 @@ private:
 
     // save as text
     OUString                    maSaveAsText;
+    OUString                    maMainMarkupText;
 
     // folder URL
     static OUString             maLastFolderURL;
@@ -237,7 +249,8 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl(
     if (mpText)
     {
         OUString aHelpId = OStringToOUString( mrParentDialog.GetHelpId(), RTL_TEXTENCODING_UTF8 );
-        mpText->SetText( lcl_ParagraphWithImage( aHelpId) );
+        maMainMarkupText = lcl_ParagraphWithImage( aHelpId);
+        mpText->SetText( maMainMarkupText );
         mpText->SetReadOnly(true);
     }
 
@@ -572,6 +585,14 @@ IMPL_LINK(ScreenshotAnnotationDlg_Impl, pictureFrameListener, VclWindowEvent&, r
                         maSelected.insert(mpHilighted);
                     }
 
+                    OUString aBookmarks;
+                    for (auto&& rCandidate : maSelected)
+                    {
+                        OUString aHelpId = OStringToOUString( rCandidate->GetHelpId(), RTL_TEXTENCODING_UTF8 );
+                        aBookmarks += lcl_Bookmark( aHelpId );
+                    }
+
+                    mpText->SetText( maMainMarkupText + aBookmarks );
                     bRepaint = true;
                 }
                 break;
commit 3298e8b8ec18a8aa76c7d0410d2b18d35471aec9
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Tue Oct 18 19:29:00 2016 +0200

    screenshot annotation: Display markup for embedding the image
    
    Change-Id: I06fd744fabd66ee02123790718a899d9e0dcb6b7

diff --git a/cui/source/dialogs/screenshotannotationdlg.cxx b/cui/source/dialogs/screenshotannotationdlg.cxx
index 357e9b1..2f7c2d6 100644
--- a/cui/source/dialogs/screenshotannotationdlg.cxx
+++ b/cui/source/dialogs/screenshotannotationdlg.cxx
@@ -27,6 +27,8 @@
 #include <com/sun/star/ui/dialogs/FilePicker.hpp>
 #include <com/sun/star/ui/dialogs/TemplateDescription.hpp>
 #include <com/sun/star/ui/dialogs/ExecutableDialogResults.hpp>
+
+#include <comphelper/random.hxx>
 #include <vcl/pngwrite.hxx>
 #include <basegfx/polygon/b2dpolygontools.hxx>
 #include <tools/urlobj.hxx>
@@ -40,6 +42,44 @@
 
 using namespace com::sun::star;
 
+namespace
+{
+    OUString lcl_genRandom( const OUString &rId )
+    {
+        //FIXME: plus timestamp
+        unsigned int nRand = comphelper::rng::uniform_uint_distribution(0, 0xFFFF);
+        return OUString( rId + OUString::number( nRand ) );
+    }
+
+
+    OUString lcl_AltDescr()
+    {
+        OUString aRet = OUString("<alt xml-lang=en-US ") + OUString("id=") + lcl_genRandom("alt_id") + OUString(">") +
+                        OUString(" ") + //FIXME real dialog title or something
+                        OUString("</alt>");
+        return aRet;
+    }
+
+    OUString lcl_Image( const OUString& rScreenshotId )
+    {
+        OUString aRet = OUString("<image id=") + lcl_genRandom( "img_id" ) +
+                        OUString(" src=media/screenshots/") + rScreenshotId + OUString(".png")
+                        + OUString(">") + //FIXME width + height
+                        lcl_AltDescr() +
+                        OUString("</image>");
+        return aRet;
+    }
+
+    OUString lcl_ParagraphWithImage( const OUString& rScreenshotId )
+    {
+        OUString aRet = OUString("<paragraph id=") + lcl_genRandom( "par_id" ) +
+                        OUString(" role=\"paragraph\" xml-lang=en-US>") +
+                        lcl_Image( rScreenshotId ) +
+                        OUString("</paragraph>");
+        return aRet;
+    }
+}
+
 class ControlDataEntry
 {
 public:
@@ -196,8 +236,9 @@ ScreenshotAnnotationDlg_Impl::ScreenshotAnnotationDlg_Impl(
     // copying content to clipboard is allowed
     if (mpText)
     {
-        mpText->SetText("The quick brown fox jumps over the lazy dog :)");
-        mpText->SetReadOnly();
+        OUString aHelpId = OStringToOUString( mrParentDialog.GetHelpId(), RTL_TEXTENCODING_UTF8 );
+        mpText->SetText( lcl_ParagraphWithImage( aHelpId) );
+        mpText->SetReadOnly(true);
     }
 
     // set click handler for save button
commit b43888e73c761436f102b61e21d00825b6813a18
Author: Katarina Behrens <Katarina.Behrens at cib.de>
Date:   Thu Sep 29 16:26:18 2016 +0200

    screenshot annotation: tweak dialog a bit
    
    Add some descriptive labels
    Remove OK button (redundant in this context, Save Screenshot... does
    the job)
    
    Change-Id: I36e32986f777675f297390b691f2cd1681a0eaa2

diff --git a/cui/uiconfig/ui/screenshotannotationdialog.ui b/cui/uiconfig/ui/screenshotannotationdialog.ui
index 6ab3436..71f0dff 100644
--- a/cui/uiconfig/ui/screenshotannotationdialog.ui
+++ b/cui/uiconfig/ui/screenshotannotationdialog.ui
@@ -1,5 +1,5 @@
 <?xml version="1.0" encoding="UTF-8"?>
-<!-- Generated with glade 3.16.1 -->
+<!-- Generated with glade 3.18.3 -->
 <interface>
   <requires lib="gtk+" version="3.0"/>
   <object class="GtkDialog" id="ScreenshotAnnotationDialog">
@@ -15,40 +15,11 @@
         <property name="can_focus">False</property>
         <property name="orientation">vertical</property>
         <property name="spacing">12</property>
-        <child>
-          <object class="GtkImage" id="picture">
-            <property name="name">picture</property>
-            <property name="visible">True</property>
-            <property name="can_focus">False</property>
-            <property name="stock">gtk-missing-image</property>
-          </object>
-          <packing>
-            <property name="expand">True</property>
-            <property name="fill">True</property>
-            <property name="position">0</property>
-          </packing>
-        </child>
         <child internal-child="action_area">
           <object class="GtkButtonBox" id="dialog-action_area1">
             <property name="can_focus">False</property>
             <property name="layout_style">end</property>
             <child>
-              <object class="GtkButton" id="ok">
-                <property name="label">gtk-ok</property>
-                <property name="visible">True</property>
-                <property name="can_focus">True</property>
-                <property name="can_default">True</property>
-                <property name="has_default">True</property>
-                <property name="receives_default">True</property>
-                <property name="use_stock">True</property>
-              </object>
-              <packing>
-                <property name="expand">False</property>
-                <property name="fill">True</property>
-                <property name="position">0</property>
-              </packing>
-            </child>
-            <child>
               <object class="GtkButton" id="cancel">
                 <property name="label">gtk-cancel</property>
                 <property name="visible">True</property>
@@ -87,6 +58,46 @@
           </packing>
         </child>
         <child>
+          <object class="GtkLabel" id="label2">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes">Click the widgets to add annotation:</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">0</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkImage" id="picture">
+            <property name="name">picture</property>
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="stock">gtk-missing-image</property>
+          </object>
+          <packing>
+            <property name="expand">True</property>
+            <property name="fill">True</property>
+            <property name="position">1</property>
+          </packing>
+        </child>
+        <child>
+          <object class="GtkLabel" id="label1">
+            <property name="visible">True</property>
+            <property name="can_focus">False</property>
+            <property name="halign">start</property>
+            <property name="label" translatable="yes">Paste the following markup into the help file:</property>
+            <property name="ellipsize">end</property>
+          </object>
+          <packing>
+            <property name="expand">False</property>
+            <property name="fill">True</property>
+            <property name="position">3</property>
+          </packing>
+        </child>
+        <child>
           <object class="GtkTextView" id="text">
             <property name="name">text</property>
             <property name="height_request">80</property>
@@ -96,7 +107,7 @@
           <packing>
             <property name="expand">False</property>
             <property name="fill">True</property>
-            <property name="position">2</property>
+            <property name="position">4</property>
           </packing>
         </child>
       </object>


More information about the Libreoffice-commits mailing list